#define _CRT_SECURE_NO_WARNINGS 1


 struct ListNode {
      int val;
     struct ListNode *next;
 };
 
struct ListNode* middleNode(struct ListNode* head) {
    /*int count = 0;
    struct ListNode* prev = head, * cur = head;
    if (!head || !(head->next)) return head;
    else
    {
        while (cur)
        {
            cur = cur->next;
            count++;
        }
        count = count / 2;
        while (count--)
        {
            prev = prev->next;
        }
        head = prev;
        return head;
    }*/
    struct ListNode* slow = head, * fast = head;
    while (fast && fast->next)
    {
        slow = slow->next;
        fast = fast->next->next;
    }
    return slow;
}